home *** CD-ROM | disk | FTP | other *** search
/ Gamers Delight 2 / Gamers Delight 2.iso / Aminet / game / board / FiveInLine.lha / FiveInLine / Source / idcmp.c < prev    next >
C/C++ Source or Header  |  1994-04-20  |  2KB  |  99 lines

  1. #include <exec/exec.h>
  2. #include <proto/exec.h>
  3.  
  4. #include <intuition/intuition.h>
  5. #include <proto/intuition.h>
  6.  
  7. #include <libraries/gadtools.h>
  8. #include <proto/gadtools.h>
  9.  
  10. #include "fil.h"
  11.  
  12. extern struct Window    *mwWnd;
  13. extern struct Menu        *mwMenus;
  14. extern BOOL                player;
  15. extern UWORD            offx;
  16. extern UWORD            offy;
  17.  
  18. int handleidcmp ( int *amiga_old_row, int amiga_old_col, BOOL *terminated, FLOAT *playlevel )
  19. {
  20.     struct IntuiMessage    mwMsg;
  21.     struct IntuiMessage    *m;
  22.     struct MenuItem        *item;
  23.     BOOL                running = TRUE;
  24.  
  25.     Wait ( 1 << mwWnd->UserPort->mp_SigBit );
  26.  
  27.     while ( mwWnd && ( m = GT_GetIMsg ( mwWnd->UserPort ) ) ) {
  28.  
  29.         CopyMem ( ( char * )m, ( char * ) &mwMsg, ( long ) sizeof ( struct IntuiMessage ) );
  30.  
  31.         GT_ReplyIMsg ( m );
  32.  
  33.         switch ( mwMsg.Class ) {
  34.  
  35.             case    IDCMP_REFRESHWINDOW:
  36.                 GT_BeginRefresh ( mwWnd );
  37.                 drawboard ();
  38.                 GT_EndRefresh ( mwWnd, TRUE );
  39.                 break;
  40.  
  41.             case    IDCMP_CLOSEWINDOW:
  42.                 closedownwindow ( terminated );
  43.                 running = FALSE;
  44.                 break;
  45.  
  46.             case    IDCMP_MENUPICK:
  47.                 while ( mwMsg.Code != MENUNULL && running ) {
  48.                     item = ItemAddress ( mwMenus, mwMsg.Code );
  49.  
  50.                     switch ( MENUNUM ( mwMsg.Code ) ) {
  51.                         case 0: /* Project */                    
  52.                             switch ( ITEMNUM ( mwMsg.Code ) ) {
  53.                                 case 0:
  54.                                     running = showabout ();
  55.                                     break;
  56.                                 case 2:
  57.                                     closedownwindow ( terminated );
  58.                                     running = FALSE;
  59.                                     break;
  60.                             }
  61.                             break;
  62.                         case 1: /* Amiga Playing Level */
  63.                             switch ( ITEMNUM ( mwMsg.Code ) ) {
  64.                                 case 0:
  65.                                     *playlevel = LEVEL5;
  66.                                     SetWindowTitles ( mwWnd, LEVELTEXT5, ( UBYTE * ) ~ 0 );
  67.                                     break;
  68.                                 case 1:
  69.                                     *playlevel = LEVEL4;
  70.                                     SetWindowTitles ( mwWnd, LEVELTEXT4, ( UBYTE * ) ~ 0 );
  71.                                     break;
  72.                                 case 2:
  73.                                     *playlevel = LEVEL3;
  74.                                     SetWindowTitles ( mwWnd, LEVELTEXT3, ( UBYTE * ) ~ 0 );
  75.                                     break;
  76.                                 case 3:
  77.                                     *playlevel = LEVEL2;
  78.                                     SetWindowTitles ( mwWnd, LEVELTEXT2, ( UBYTE * ) ~ 0 );
  79.                                     break;
  80.                                 case 4:
  81.                                     *playlevel = LEVEL1;
  82.                                     SetWindowTitles ( mwWnd, LEVELTEXT1, ( UBYTE * ) ~ 0 );
  83.                                     break;
  84.                             }
  85.                             break;
  86.                         }
  87.                     mwMsg.Code = item->NextSelect;
  88.                 }
  89.                 break;
  90.  
  91.             case    IDCMP_MOUSEBUTTONS:
  92.                 running = handlemousebuttons ( m , amiga_old_row, amiga_old_col );
  93.                 break;
  94.  
  95.         }
  96.     }
  97.     return ( running );
  98. }
  99.